package Eksamensporjekt1sem;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.JToggleButton;
import javax.swing.JTextPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.Font;
import javax.swing.JCheckBox;
import java.awt.SystemColor;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.JToolBar;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;


public class Management {

	private JFrame frmManagement;
	
	private JTable table;
	private String fornavn;
	private String efternavn;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Management window = new Management();
					window.frmManagement.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	
	

	/**
	 * Create the application.
	 * @throws IOException 
	 */
	public Management() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 * @throws FileNotFoundException 
	 * @throws IOException 
	 */
	private void initialize()  {
		frmManagement = new JFrame();
		frmManagement.setTitle("Rend og Hop Management");
		frmManagement.setBounds(100, 100, 780, 593);
		frmManagement.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frmManagement.getContentPane().setLayout(null);
		OpretMedlemKode omk = new OpretMedlemKode();
		OpretMedlem om = new OpretMedlem();
		try {
			omk.hentMedlem();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		table = new JTable();
		table.setShowVerticalLines(false);
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		table.setBorder(new LineBorder(new Color(0, 0, 0)));
		table.setBackground(SystemColor.menu);
		table.setFont(new Font("Tahoma", Font.PLAIN, 14));
		table.setModel(new DefaultTableModel(
			
				new Object[][] {
				{"Navn", "CPR nr.", "Aktivitetsform", "Niveau", "Konkurrence", "Point", "Kontingent"},
				{omk.getFornavn2() + " " + omk.getEfternavn2(),  "-" + omk.getSidstefire(), "Konkurrence", "Mikro", "Rytme", "30", "Kr. ", "1600"},
				
			},
			new String[] {
				"Navn", "CPR nr.", "Aktivitetsform", "Niveau", "Konkurrence", "Point", "Kontingent"
			}
		));
		table.getColumnModel().getColumn(0).setPreferredWidth(80);
		table.getColumnModel().getColumn(1).setPreferredWidth(80);
		table.getColumnModel().getColumn(2).setPreferredWidth(80);
		table.getColumnModel().getColumn(3).setPreferredWidth(80);
		table.getColumnModel().getColumn(4).setPreferredWidth(80);
		table.getColumnModel().getColumn(5).setPreferredWidth(80);
		table.getColumnModel().getColumn(6).setPreferredWidth(80);
		table.setBounds(10, 47, 746, 160);
		frmManagement.getContentPane().add(table);
		
		JToolBar toolBar = new JToolBar();
		toolBar.setFloatable(false);
		toolBar.setBackground(SystemColor.inactiveCaption);
		toolBar.setBounds(0, 0, 764, 29);
		frmManagement.getContentPane().add(toolBar);
		
		JButton btnRestance = new JButton("Betaling");
		btnRestance.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Betaling b = new Betaling();
				b.getFrame().show();
			}
		});
		btnRestance.setFont(new Font("Tahoma", Font.PLAIN, 13));
		toolBar.add(btnRestance);
		
		JButton btnTop = new JButton("Top 7");
		btnTop.setFont(new Font("Tahoma", Font.PLAIN, 13));
		toolBar.add(btnTop);
	}

	public JFrame getFrmManagement() {
		return frmManagement;
	}

	public void setFrmManagement(JFrame frmManagement) {
		this.frmManagement = frmManagement;
	}
}
